package com.example.fist.control;

import com.example.fist.dao.WinningDao;
import com.example.fist.entity.WinningEntity;
import com.example.fist.personRepository.WinningRepository;
import com.example.fist.util.Json.ErrorJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class Winning {

    @Autowired
    private WinningRepository winningRepository;
    @RequestMapping("/winning/add")
    public  String add(String name,String company,String coName,String grade,String
            awards,String winningTime,String trend){
        WinningEntity winningEntity=new WinningEntity();
        winningEntity.setName(name);
        winningEntity.setCompany(company);
        winningEntity.setCoName(coName);
        winningEntity.setGrade(grade);
        winningEntity.setAwards(awards);
        System.out.println(winningTime);
        winningEntity.setWinningTime(new Date());
        winningEntity.setTrend(trend);
        WinningDao winningDao=new WinningDao(winningRepository);
        winningDao.add(winningEntity);
        return new ErrorJson(200,"Ok@@").toString();
    }
}
